#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    bool isSameTree(TreeNode* root, TreeNode* subRoot)
    {
        if (root == nullptr && subRoot == nullptr)
        {
            return true;
        }
        if (root == nullptr || subRoot == nullptr)
        {
            return false;
        }
        if (root->val != subRoot->val)
        {
            return false;
        }
        return isSameTree(root->left, subRoot->left) && isSameTree(root->right, subRoot->right);
    }
    bool isSubtree(TreeNode* root, TreeNode* subRoot) {
        if (root == nullptr)
        {
            return false;
        }
        if (root->val == subRoot->val && isSameTree(root, subRoot))
        {
            return true;
        }
        return isSubtree(root->left, subRoot) || isSubtree(root->right, subRoot);
    }
};